package com.ksana.bean.factory.config;

import com.ksana.bean.PropertyValue;
import com.ksana.bean.PropertyValues;

import java.util.ArrayList;
import java.util.List;

public class BeanDefinition {
    private Class<?> bean;
    private PropertyValues propertyValues;
    private String initMethodName;
    private String destroyMethodName;

    private final String SCOPE_SINGLETON = "singleton";
    private final String SCOPE_PROTOTYPE = "prototype";

    private String scope = SCOPE_SINGLETON;

    public BeanDefinition(Class<?> bean) {
        this(bean, null);
    }

    public BeanDefinition(Class<?> bean, PropertyValues propertyValues) {
        this.bean = bean;
        this.propertyValues = propertyValues == null ? new PropertyValues() : propertyValues;
    }

    public Class<?> getBean() {
        return bean;
    }

    public void setBean(Class<?> bean) {
        this.bean = bean;
    }

    public PropertyValues getPropertyValues() {
        return propertyValues;
    }

    public void setPropertyValues(PropertyValues propertyValues) {
        this.propertyValues = propertyValues;
    }

    public String getInitMethodName() {
        return initMethodName;
    }

    public void setInitMethodName(String initMethodName) {
        this.initMethodName = initMethodName;
    }

    public String getDestroyMethodName() {
        return destroyMethodName;
    }

    public void setDestroyMethodName(String destroyMethodName) {
        this.destroyMethodName = destroyMethodName;
    }

    public String getScope() {
        return scope;
    }

    public void setScope(String scope) {
        this.scope = scope;
    }

    public boolean isSingleton() {
        return SCOPE_SINGLETON.equals(this.scope);
    }

    public boolean isProperty() {
        return SCOPE_PROTOTYPE.equals(this.scope);
    }
}
